import request from '@/config/axios'

// 会员权益 VO
export interface BenefitVO {
  id: number // 主键ID
  icon: string // 权益图标
  name: string // 权益名称
  type: number // 权益类型(1=基础权益 2=增值权益 3=专属权益
  relatedElement: string // 关联元素
  tagIds: string // 关联标签
  tagNames?: string[] // 关联标签名称
  description: string // 权益描述
  sort: number // 显示排序
  status: number // 状态
}

// 会员权益 API
export const BenefitApi = {
  // 查询会员权益分页
  getBenefitPage: async (params: any) => {
    return await request.get({ url: `/member/benefit/page`, params })
  },

  // 查询会员权益详情
  getBenefit: async (id: number) => {
    return await request.get({ url: `/member/benefit/get?id=` + id })
  },

  // 查询会员权益 - 精简信息列表
  getSimpleBenefitList: async () => {
    return await request.get({ url: `/member/benefit/list-all-simple` })
  },

  // 新增会员权益
  createBenefit: async (data: BenefitVO) => {
    return await request.post({ url: `/member/benefit/create`, data })
  },

  // 修改会员权益
  updateBenefit: async (data: BenefitVO) => {
    return await request.put({ url: `/member/benefit/update`, data })
  },

  // 删除会员权益
  deleteBenefit: async (id: number) => {
    return await request.delete({ url: `/member/benefit/delete?id=` + id })
  },

  // 批量删除会员权益
  deleteBenefitList: async (ids: number[]) => {
    return await request.delete({ url: `/member/benefit/delete-batch`, data: ids })
  },

  // 导出会员权益 Excel
  exportBenefit: async (params) => {
    return await request.download({ url: `/member/benefit/export-excel`, params })
  }
}
